package main

import (
	"encoding/gob"
	"os"
	"fmt"
)

type P1 struct {
	FirstName string
	LastName string
}

type P2 struct {
	FirstName *string
	MiddleName *string
	LastName *string
}

func main() {
	p1:=P1{"fname", "lname"}

	f,_:=os.OpenFile("data", os.O_WRONLY | os.O_CREATE, 0666)
	enc:=gob.NewEncoder(f)
	enc.Encode(p1)
	f.Close()

	p2:=new(P2)
	f2,_:=os.Open("data")
	dec:=gob.NewDecoder(f2)
	dec.Decode(p2)
	fmt.Printf("%+v\n", p2)
	fmt.Println(*p2.FirstName)
	fmt.Println(*p2.LastName)
}
